package org.ece3574.WTParty;


import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TabHost;

public class tabbedUIActivity extends TabActivity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Reusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, MeActivity.class);

        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("me").setIndicator("Me",
                          res.getDrawable(R.drawable.graduate)) //each tab has its icon specified
                      .setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, MapScreenActivity.class);
        spec = tabHost.newTabSpec("map").setIndicator("Map",
                          res.getDrawable(R.drawable.globe)) // tab icon
                      .setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, FBTestActivity.class);
        spec = tabHost.newTabSpec("friends").setIndicator("Friends",
                          res.getDrawable(R.drawable.human)) // tab icon
                      .setContent(intent);
        tabHost.addTab(spec);

        tabHost.setCurrentTab(0);
    }
    
    // menu options implementation
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu1, menu);
        return true;
    }
    
    
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
    	Intent intent1;
        switch (item.getItemId()) {
        
	        case R.id.Events:	intent1 = new Intent().setClass(this, EventsList.class);
			startActivity(intent1);
			break;
			
            case R.id.Exit: this.finish();
                                break;
        }
        return true;
    }
    
}